<?php

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Application\Model\Entity\User;
use Application\Model\Entity\Project;

class IndexController extends AbstractActionController
{
    protected $_objectManager;
    
    public function indexAction()
    {  
        $projects = $this->getObjectManager()->getRepository('\Application\Model\Entity\Project')->findBy(array('id' => array(1,2,3)));

        $users = $this->getObjectManager()->getRepository('\Application\Model\Entity\User')->findAll();
        $categories = $this->getObjectManager()->getRepository('\Application\Model\Entity\Category')->findAll();
        
        return new ViewModel(array(
                'projects' => $projects,
                'users'    => $users,
                'categories' => $categories,
                ));
    }
    
    protected function getObjectManager()
    {
                
        if (!$this->_objectManager) {
            $this->_objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
        }

        return $this->_objectManager;
    }
}
